package qf.sail.controller;

import qf.sail.entity.Account;
import qf.sail.entity.OrderItem;
import qf.sail.service.ShopCarService;
import qf.sail.service.impl.ShopCarServiceImpl;
import qf.sail.vo.ResultVO;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/getShopCar")
public class GetShopCarServlet extends BaseServlet{
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ShopCarService shopCarService = new ShopCarServiceImpl();
        Account account = (Account) req.getSession().getAttribute("account");
        //获取成购物车子项
        List<OrderItem> items = shopCarService.getItemsByShopCarId(account.getId());
        ResultVO resultVO = new ResultVO();
        resultVO.addData("items",items);
        repSuccess(resp,resultVO);

    }
}
